package com.Ajava1801D.设计模式.原型模式;

import org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream;

import java.io.*;
import java.util.List;
import java.util.Map;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2020/10/12  14:58
 * 描述:
 */
public class YuanXinglei implements Cloneable,Serializable {

    private List<Map<String,List<String>>> list;

    private int i=5;

    private Integer intt=1;


    public void setList(List<Map<String, List<String>>> list) {
        this.list = list;
    }

    public void setI(int i) {
        this.i = i;
    }

    public void setIntt(Integer intt) {
        this.intt = intt;
    }


    public List<Map<String, List<String>>> getList() {
        return list;
    }

    public int getI() {
        return i;
    }

    public Integer getIntt() {
        return intt;
    }

    //浅克隆
    @Override
    protected YuanXinglei clone() throws CloneNotSupportedException {
        return (YuanXinglei)super.clone();
    }

    /**
     * 作者: LCG
     * 日期: 2020/10/12  15:07
     * 描述: 深克隆
     * @Param []
     * @Return com.Ajava1801D.设计模式.原型模式.YuanXinglei
     */
    public YuanXinglei deepClone() throws IOException, ClassNotFoundException {

        ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream();
        ObjectOutputStream objectOutputStream=new ObjectOutputStream(byteArrayOutputStream);
        objectOutputStream.writeObject(this);

        ByteArrayInputStream byteArrayInputStream=new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
        ObjectInputStream objectInputStream=new ObjectInputStream(byteArrayInputStream);

        return (YuanXinglei)objectInputStream.readObject();


    }


}
